Copyright: Visual Help Copyright® 1993 Firas Bushnaq


Distribution Function Help

This program calculates probabilities for some of the more important continuous distribution functions. It also calculates the power function and sample sizes for  the normal and t-tests on means.

The go button starts the calculations, the Q button closes the window, and the H button calls up the help file for the dialog. You may also press the enter key to start the calculation.

The main menu functions are:

Normal Probs

t distribution

Chi square distribution

F and beta distribution

Power functions and Sample Sizes

Statistical Comparisons

If you like this program and use it regularly, please send $10 US to

Mark Von Tress
PO Box 171173
Arlington TX 76003


NORMAL PROBS
Normal Probabilities

•	Probs: Enter a standard normal variable, z, and get the probabablity less than or equal to z.

•	Mean Std Probs: Enter a normal random variable, X=x, having mean, mean, and standard deviation, std. Prob is the probability that X<=x.

Percentiles

•	Quantile: Enter the probability, q. z is the value of a standard normal random variable having probability q less than or equal to it. It is the 100*q'th percentile.

•	Inv Nm std: Enter the probability, prob, mean and standard deviation,std. x is the value of a normal random variable with mean and std dev. having probability prob less than or equal to it.


t distribution

•	Prob: enter t, and the degrees of freedom, df. Returns prob=P(T(df) <= t )

•	inverse t: enter prob, and the degrees of freedom, df. Returns t such that
prob = P(T(df) <= t ).

Non central t distribution

•	Non central t: enter t, the degrees of freedom, df, and the non-centrality parameter, nc(>0). Returns prob=P(T(df,nc) <= t ). Non centrality parameter matches SAS usage.

•	nct quantiles: enter prob, the degrees of freedom, df, and the non-centrality parmeter, nc(>0). Returns t such that prob = P(T(df,nc) <= t ).


CHI SQUARE PROBS
Chi-Square Probs

•	Chi-square: Input chi-square, chi, and degrees of freedom, df. Returns prob=P(X(df)<chi )

•	Inv ChiSquare: Input prob, and degrees of freedom. Returns x such that prob=P(X(df)<x)

Non-Central Chi Square

•	NC ChiSquare: input non-central chi square variate, chi,  the degrees of freedom, df, and the non-centrality parameter.  Returns prob = P( X(df,nc) < chi). Note, noncentrality parameter is 2*lambda in Abramowitz and Stegun equation 26.4.25. Handbook of Mathematical Functions. Also the noncentrality parameter matches the use in SAS.

•	Inv NCChiSqr: Inverse non-central Chi-square, input prob, df, and nc. Returns x such that prob=P( X(df,nc)<x)

Gamma Distribution

•	Gamma: Input gamma variate, g, alpha, a, and beta, b. Returns prob=P(G(a,b)<g).

•	InvGamma: Input prob, alpha, a, and beta b. Returns g such that prob=P(G(a,b)<g)


F AND BETA PROBS
F distribution

•	Fdist: input F variate, f, degrees of freedom df1,df2. Return prob=P(F(df1,df2)<f).

•	Invf: input prob, degrees of freedom df1,df2. Return f such that prob=P(F(df1,df2)<f).

NonCentral F

•	NonCentralF: input F variate, f, degrees of freedom df1,df2, and noncentrality parameter. Return prob=P(F(df1,df2,nc)<f). The non-centrality parameter matches SAS.

•	Ncf inverse: input prob, degrees of freedom df1,df2, and noncentrality parameter. Return f such that prob=P(F(df1,df2,nc)<f). The non-centrality parameter matches SAS.

Beta

•	Beta: input beta variate, x, alpha, a, and beta, b. Returns prob=P(B(a,b)<x).


Power Functions and Sample Size

The power functions and sample size menus calculate the power of hypothesis tests and sample sizes for several well known statistical tests.  The 1 sample tests compare means to a constant. The 2 sample tests compare two means. The one way anova compares several means. The last two tests compare two proportions.

The sample sizes in the 2 sample tests are for a single group. The total sample requirements are twice the presented sample size. Also the one-way anova presents a sample size for each group.

The menus are fairly similar. You select the parameter to solve for by using a radio button. Then you input the other information needed to describe the test. Then click on the go button with the mouse, or press the enter key. You can get help using the H button.

Normal Tests

T-tests

One-way Anova

Compare Percentages

Fisher's Exact Test


Normal Tests

These calculate power and sample size for the 1 and 2 sample tests on normal means.

Z test 1 sample:

Select a left, right, or 2-sided alternative using the Sides radio button.  Select the parameter to solve for using the 'Solve for' radio button. Enter the type 1 error, alpha, the standard deviation, and the size of the difference to detect. Enter the sample size if solving for the power, and enter power if solving for the sample size. Select the go button to calculate the selected parameter.

Z test 2 sample:

Select a left, right, or 2-sided alternative using the Sides radio button.  Select the parameter to solve for using the 'Solve for' radio button. Enter the type 1 error, alpha, the standard deviation, and the size of the difference to detect. Enter the sample size if solving for the power, and enter power if solving for the sample size. Select the go button to calculate the selected parameter.

Note that if the sample size is 5000 or more, then only the 5000 is reported. You might consider another test if you need that much data. The sample size is represented as +5000.

See Also

One-Sample Tests

Two-Sample Tests


One Sample Tests

The one sample tests compare a mean to a constant. The standard normal test, and t-test are calculated. The standard normal test is used in small samples where the variance is known. The t-test is used in small samples where the variance is unknown. The give very similar results in large samples.

The basic idea is to measure the difference between a sample average (m) and a constant (c) to the standard deviation of the mean (s/sqrt(n)). If this difference is large relative to the scale for the mean, then we can conclude the difference is statistically significant.

These dialogs can be used for actually making the test, or for planning purposes. These dialogs have a Go button, a Q button, and an H button. You input the parameters for the test.

Input  Box

•	Mean m, standard deviation std ( > 0), and sample size n(  > 1).

•	Constant c: the constant for comparison. Usually this is zero, but you can use it to calculate the sample size needed to detect a difference with a given power. Fix the delta, m-c, that is meaningful to the given problem, then increment the sample size until the desired power is achieved in the output box.

•	alpha: Probability of a type 1 error. This is the probability of incorrectly rejecting H0.  This is used in the power calculation for determining the size critical region.

•	sides: direction of the alternative hypothesis. A left tail test has the alternative HA: m-c < 0, A right tail test has HA: m-c>0, and the two tail test has HA: m != c.

Output Box

•	z or t: the test statistic above. It is the number of standard errors of the mean by which the mean and constant differ.

•	std err: standard error of the mean  s/sqrt(n).

•	power : size of the critical region under the alternative hypothesis. This is the probability of correctly rejecting the null hypothesis, ie the probability of rejecting H0 when H0 is incorrect. Usually you want a sample size that insures the power is greater than 0.8. The type II error  is 1-power, and is the probability of failing to reject HO when the alternative is true. Thus, 80% power indicates that there is a 1 in 5 chance of failing to reject the null when it is false.

•	p-value : probability of a more extreme value of the test statistic. Usually you reject the null hypothesis if the p-value is less than alpha, the probabability of an incorrect rejection of the null

•	delta : the difference between the mean and the constant.

See Also

Normal Tests

t-tests


t Tests

TTest 1 Sample

Select a left, right, or 2-sided alternative using the Sides radio button.  Select the parameter to solve for using the 'Solve for' radio button. Enter the type 1 error, alpha, the standard deviation, and the size of the difference to detect. Enter the sample size if solving for the power, and enter power if solving for the sample size. Select the go button to calculate the selected parameter.

TTest 2 Sample

Select a left, right, or 2-sided alternative using the Sides radio button.  Select the parameter to solve for using the 'Solve for' radio button. Enter the type 1 error, alpha, the standard deviation, and the size of the difference to detect. Enter the sample size if solving for the power, and enter power if solving for the sample size. Select the go button to calculate the selected parameter.

Note that if the sample size is 5000 or more, then only the 5000 is reported. You might consider another test if you need that much data. The sample size is represented as +5000.

See Also

One-Sample Tests

Two-Sample Tests


Two Sample Tests

The two sample tests compare a difference in means to a constant. Usually the constant is zero, so the tests usually compare means.

The standard normal test, and two kinds of t-tests are calculated. The standard normal test is used in small samples where the group variances are known. The t-test is used in small samples where the group variances are unknown but assumed equal.

Another t-test is provided when the  group variances are unknown, but assumed unequal. The second t-test is based on Satterthwaite's method, and has continuous degrees of freedom. There is an F-test for deciding on which t-test to use.

These dialogs can be used for actually making the test, or for planning purposes. These dialogs have a Go button, a Q button, and an H button. You input the parameters for the test.

Input box

•	For group 1: Mean m1, standard deviation std1 ( > 0), and sample size n1 (  > 1).

•	For group 2: Mean m2, standard deviation std2 ( > 0), and sample size n2 (  > 1).

•	Constant c: the constant for comparison. Usually this is zero, but you can use it to calculate the sample size needed to detect a difference with a given power. Fix the delta, m1-m2-c, that is meaningful to the given problem, then increment the sample sizes until the desired power is achieved in the output box.

•	alpha: Probability of a type 1 error. This is the probability of incorrectly rejecting H0.  This is used in the power calculation for determining the size critical region.

•	sides: direction of the alternative hypothesis. A left tail test has the alternative HA: m1-m2  < c, A right tail test has HA: m-m2>c, and the two tail test has HA: m1-m2 != c.

•	Variances: For the two-sample t-test only. This selects the t-test for equal or unequal variances. Usually you want to use equal variances. This is the most well known statistic. The difference between the test is in the standard error and degrees of freedom. The equations in PROC TTEST of SAS are used. Use the F for equal variances output box to determine which t-test to use. (See below)

Output Box

•	z or t: the test statistic. It is the number of standard errors of the difference in means by which the difference and constant differ.

t= (m1-m2-c)/std err

•	std err: standard error of the mean: for the z and equal variance test

 df = n1+n2-2
 sp = ((n1-1)*std1*std1+(n2-1)*std2*std2)/df
 se = sqrt( sp*(1/n1 + 1/n2))

and for the unequal variance t-test

w1=std1*std1/n1
w2=std2*std2/n2
df = (w1+w2)*(w1+w2)/(w1*w1/(n1-1)+w2*w2/(n2-1))
se = sqrt( w1+w2 )

•	power : size of the critical region under the alternative hypothesis. This is the probability of correctly rejecting the null hypothesis, ie the probability of rejecting H0 when H0 is incorrect. Usually you want a sample size that insures the power is greater than 0.8. The type II error  is 1-power, and is the probability of failing to reject HO when the alternative is true. Thus, 80% power indicates that there is a 1 in 5 chance of failing to reject the null when it is false.

•	p-value : probability of a more extreme value of the test statistic. Usually you reject the null hypothesis if the p-value is less than alpha, the probabability of an incorrect rejection of the null

•	delta : the difference between m1-m2 and the constant.

•	DF: degrees of freedom. See the standard error above.

•	F Test for Equal Variance: The F test is a two sided F test for the equality of the two group variances. It is the ratio of the maximum variance to the minimum variance. The corresponding degrees of freedom are presented. Reject the equality of variances if the pval is less than your chosen probability of a type I error for this test. You should select the appropriate entry from the variances combo box in the input section.

See Also

Normal tests

t-tests


ONEWAY  ANOVA
One-Way Anova

This a standalone program for calculating the sample size (per group) in a one way anova. It reproduces the Pearson-Hartley ANOVA power tables. The algorithm is simple minded: increase the sample size from 1 per group until the type II error rate is less than the beta you input.

Parameters

•	a = number of groups

•	mse = mean square for errors

•	ncp = non-centrality parameter (you do not need to calculate it.)

•	phi = Pearson-Hartley tables non-centrality parameter.

•	alpha = type I error (usually 0.05).

•	beta = type II error (usually 0.2 for 80% power)

•	power = 1 - beta

•	del = number of standard deviations for the largest difference between equally spaced means  (used in option 0).

•	Lower and upper bound of data to accept = Used in option 0 to filter outliers from the calculation of the mean square for errors.

Options

There are 3 options for inputting data. All three options request alpha, beta, and a.

1	Method 0: read a file of data for calculating a standard deviation. The format of the data is in rows. The first row is a string WITHOUT ANY WHITE SPACE( blanks or tabs). The second row is the number of points to read. The rest of the rows are the input data. You can also specify the range of the data you wish to accept if the data has outliers that you wish to exclude from the standard deviation.

The program calculates the standard deviation from the data. You then specify the means as being equally spaced around the average of the data. The spacing is determined as the maximum difference between equally spaced means to be del times the standard deviation. The means may increase, decrease, or be centered around the sample mean.

2	Method 1: You input a, mse, and the means. This is the most commonly used method.

3	Method 2:  Use the standard contrast, (-1 -1 2)*sqrt(mse), to calculate the sample size. You only enter a, alpha, and beta.

Output

The screen scrolls through each choice of sample size and power. Then it stops when the correct power has been found. The final output lists the means, the error mean square, the number of groups, and the the number of elements per group required for a test of size alpha with a specified power.


COMPARE PROPORTIONS
Compare Proportions: p1-p2

Select the parameter to solve for using the 'Solve for' radio button. Enter the type 1 error, alpha, the proportions, p1 and p2. Enter the sample size if solving for the power, and enter power if solving for the sample size. Select the go button to calculate the selected parameter.

Note that if the sample size is 5000 or more, then only the 5000 is reported. You might consider another test if you need that much data. The sample size is represented as +5000.


FISHERS EXACT TEST POWER
Power Function for Fisher's Exact Test

This calculates the power function for Fisher's exact test. It is a standalone program, and can be very slow for large samples. Use the p1-p2 for large samples.

This algorithm calculates the exact power function of the UMPU level alpha test for 2x2 tables. The reference for this may be found in Kendal and Stuart, Volume 2 (33.25), and Harkness, and Katz (1964), Ann. Math. Stat., V34, p1115.

Input Parameters

The input parameters are alpha:  the type 1 error rate, alpha
                         tail :  0-LEFT tailed test
                                 1-RIGHT tailed test
                                 2-TWO tailed test
                   margins:  number of fixed margins
                                  0-Double Dichotomy
                                  1-Comparative trial
                                    (row margins are fixed)
                                  2-Independence Trial

Most of the time you will want alpha = 0.05, tail = 2, and margins = 1. This corresponds to a comparison of proportions from two treatment groups.

Output

The UMPU test is output. If you ignore the randomization decision value, then you have Fisher's Exact Test. In the following, p1, and p2 are the row proportions in the first column: p1 = n11/(n11+n12), p2 = n21/(n21+n22).

•	 If n11 is one of the values where the test is 1, then n11 is in the rejection region. If n11 has a test value of zero, then it is in the acceptance region. If the test is between zero and one, then reject with probability p.

•	Next the power function is printed. In the double dichotomy, and Independence trial, the odds ratio and power is displayed. In the comparative trial, p1, p2,  p1-p2 and the power are printed.

•	The results in the observed table are displayed. For the comparative test, his includes p1, p1-p2,  the UMPU test result, the Fisher's exact test pvalue, and the power function at the observed difference.  For the double dichotomy and independence test, the log odds ratio is printed instead of the proportions in the first column.

•	The power function is plotted against the appropriate result: the log odds ratio for the double dichotomy and indepedence tests, and against the difference in proportions for the comparative tests.

Comments

Note the double dichotomy takes the most computing time, the comparative trial takes less time, and the independence trial takes the least amount of time Also note that the test calculated the randomization value for the UMPU test. If this value is set to zero, then we have the Fishers exact test. The asymptotic power function is not calculated.

See Also

p1-p2 power and sample size

Fisher's Exact Test


FET
Fisher's Exact Test

Fisher's Exact Test is the same test for three different sampling situations in 2x2 tables.

The 2x2 table of interest has a proportion in each of the cells, and the row margins. Note p..=p1.+p2., p1.=p11+p12, p2.=p21+p22. Also note a corresponding table may be written in terms of cell frequencies.

The three sampling situations are:

1	Double Dichotomy: both sets of margin totals are random during the design. Hence you take independent samples of individuals, and measure two dichotomies on the individuals. Thus each individual may fall into one of the four cells. The hypothesis being tested is

                           H0:   p11*p22 = p21*p12

or that the log odds ratio is equal to zero.

2	Comparative trial: The number of individuals is fixed in each row. The rows are usually thought of "treatments" and we wish to test the difference in row proportions of the first columns. The hypothses being tested is

                          H0:  u = ( n11/n1. - n21/n2.) = 0

3	Independence test: Both row and column margins are fixed. This is an unusual test in practice, but is the basis of the Fisher's exact test. With both margins fixed, only one of the cell frequencies may vary, say  n11. This leads to a hypergeometic distribution for the test statistic. The hypothesis being tested is

                         H0:  p11/p1. = p12/p2.

Input

Input the cell frequencies: n11, n12, n21, n22 in that order.

Output

The output is the probability of a more extreme value of the test statistic under left, right or two tailed alternatives. The two tailed alternative is the most commonly used.

See Also

p1-p2

See Fisher's Exact Test Power Function


Comparisons

The comparison menu calculates several well known test statistics. The one sample tests compare an average to a constant. The two sample tests compare two means. Fisher's exact test is used for comparing proportions.

Generally, select the parameters you want and press the go button. You can get help using the H button.

One Sample tests

Two-Sample tests

Fisher's Exact Test


enter key

The default button in the dialog for performing the calculation.


go button

Perform the calculation by clicking on it. You can also tab to it. This is the default button for the dialog window, so you can press the enter key for the calculation.


H button

The H(elp) button calls up the help file for the dialog.


power

The size of the critical region under the alternative hypothesis


Q button

You can click on it, or tab to it. The window can also be shut with Alt-F4.


sample size

Number of samples per group ("n per group" in statisticaleeze)


sample sizes

The sample size per group. ("n per group" in statisticaleeze)